package com.lxw.study.behavioral.strategy.unionfactory;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Map;

@Component
public class StrategyFactory {
    //Spring会自动将Strategy接口的实现类注入到这个Map中，key为bean id，value值则为对应的策略实现类
    @Resource
    private Map<String, Strategy> strategyMap;

    public Strategy getStrategy(String strategyName) {
        return strategyMap.get(strategyName);
    }
}
